<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/5
 * Time: 9:41
 */

namespace app\index\controller;

use think\Db;
use think\Controller;
use think\Cache;

class Base extends Controller
{
    
    public function ads()
    {
        $lists = Db ::table('index') -> where('type', 1) -> select();
        $this -> assign('lists', $lists);
        Cache ::inc('number', 1);
    }

    static public function data1($data)
    {
        $a = explode('<br>', $data);
        foreach ($a as $key => $val) {
            $b[$key] = explode('+++', $val);
            $c[] = $b[$key][1];
        }
        foreach ($c as $k => $val) {
            for ($i = 0; $i < (strlen($val)); $i++) {
                $re[$k][$i] = substr($val, $i, 1);
            }

        }
        foreach ($b as $kc => $v) {
            $b[$kc][1] = $re[$kc];
        }
        return $b;
    }

    static public function data2($data)
    {
        $a = explode('<br>', $data);
        foreach ($a as $key => $val) {
            $b[$key] = explode('+++', $val);
        }
        foreach ($b as $key => $val) {
            $c [] = explode('-', $val[0]);
            $r[] = (intval($c[$key][0])) - 1;
            array_push($b[$key], $r[$key]);

        }
        return $b;
    }

}